# Archlive <http://archlive-pkg.googlecode.com>
#
#  Transfer unifiedkernel ubuntu package to Arch

pkgname=unifiedkernel
pkgver=0.3.0
pkgrel=1
##############################
#  CUSTOMIZATION
_base_kver=2.6.34
_kernver=${_base_kver}-uk-${pkgver}

kver_file=unifiedkernel.kver
preset_file=unifiedkernel.preset
kernel_name=vmlinuz-${_kernver}
default_img=unifiedkernel.img
fallback_img=unifiedkernel-fallback.img
install_file=kernel26.install
##############################
[ "${install_file}" != "kernel26.install" ] && cp -f $startdir/kernel26.install $startdir/${install_file}
url="http://www.longene.org/"
pkgdesc="The Linux Kernel and modules, with unifiedkernel patch and module"
arch=('i686')
license=('GPL2')
depends=('coreutils' 'module-init-tools' 'mkinitcpio>=0.5.15')
makedepends=('binutils')
backup=()
provides=("kernel26=${_base_kver}" "kernel26-headers=${_base_kver}" "kernel26-firmware=${_base_kver}")
conflicts=('kernel24' 'kernel24-scsi' 'kernel26-scsi')
install=${install_file}
source=(
	$pkgname-$pkgver-kernel.deb::"http://www.longene.org/fileDownload.php?id=57&page=download"
	# source code
	# longene-0.3.0.tar.bz2::"http://www.longene.org/fileDownload.php?id=49&page=download"
	# Full source 2.6.24
	# longene-0.3.0-linux-2.6.24.tar.bz2::"http://www.longene.org/fileDownload.php?id=56&page=download"
	unifiedkerneld
	)
md5sums=()

build()
{
	cd $srcdir
	ar x $pkgname-$pkgver-kernel.deb
	tar -xpf data.tar.gz -C $pkgdir/
	rm -rf $pkgdir/etc

	msg2 "Updating module dependencies..."
	depmod -a -b $pkgdir ${_kernver}

	msg2 "Installing rc scripts"
	install -Dm755 $startdir/unifiedkerneld $pkgdir/etc/rc.d/unifiedkerneld

	mkdir -p $pkgdir/etc/mkinitcpio.d

	msg2 "Generating ${kver_file}..."
	echo -e "# DO NOT EDIT THIS FILE\nALL_kver='$_kernver'" \
		> "$pkgdir/etc/mkinitcpio.d/${kver_file}" || return 1

	msg2 "Generating preset file..."
	echo -e "# mkinitcpio preset file for $pkgname\n \
		\n########################################\
		\n# DO NOT EDIT THIS LINE:\
		\nsource /etc/mkinitcpio.d/${kver_file}\
		\n########################################\
		\nALL_config=\"/etc/mkinitcpio.conf\"\
		\n\nPRESETS=('default' 'fallback')\
		\n\n#default_config=\"/etc/mkinitcpio.conf\" \
		\ndefault_image=\"/boot/${default_img}\" \
		\n#default_options=\"\" \
		\n#fallback_config=\"/etc/mkinitcpio.conf\" \
		\nfallback_image=\"/boot/${fallback_img}\" \
		\nfallback_options=\"-S autodetect\" "\
		> "$pkgdir/etc/mkinitcpio.d/${preset_file}" || return 1

	msg2 "Update install scripts..."
	sed -i "s%pkgname=.*%pkgname=${pkgname}%g;\
		s%kernelname=.*%kernelname=${kernel_name}%g;\
		s%default_img=.*%default_img=${default_img}%g;\
		s%fallback_img=.*%fallback_img=${fallback_img}%g;\
		s%preset_file=.*%preset_file=${preset_file}%g"\
		$startdir/${install_file} || return 1
}
md5sums=('6ce591073b32ec52e6bde202f480a467'
         '2e10f33b2f3552b04cd1dc63f01b6ba0')
